<?php

use yii\db\Schema;
use yii\db\Migration;

class m160125_104504_add_condition_adspace_adnetwork extends Migration
{
    public function up()
    {
        $sql = <<<FINE
CREATE TABLE {{%condition_adspace_adnetwork}} (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `solution_id` int(11) unsigned NOT NULL,
  `is_whitelist` int(1) NOT NULL DEFAULT '0' COMMENT '0 blacklist, 1 whitelist',
  `adnetwork` int(11) NOT NULL COMMENT 'ssp id 集合，逗号分割',
  `status` int(1) NOT NULL DEFAULT '1' COMMENT '1 有效， 0 无效（删除或其他情况）',
  `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

insert into {{%condition_type}} (name, table_name, is_for_display, is_for_video, is_for_mobile, status) values ('渠道定向', 'condition_adspace_adnetwork', 1, 1, 1, 1);
FINE;
        $this->execute($sql);
        
    }

    public function down()
    {
        return $this->dropTable('{{%condition_adspace_adnetwork}}');
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}
